package cn.hbads.version.domain.version.aggregate;

import cn.hbads.support.error.ErrorType;
import cn.hbads.support.structure.result.OpResult;
import cn.hbads.version.domain.version.model.BusinessModel;
import cn.hbads.version.domain.version.model.ChangePoint;
import cn.hbads.version.domain.version.model.DataVersionModifyModel;

import java.time.LocalDate;
import java.util.Collection;
import java.util.Optional;

/**
 * <b>数据版本链通用规范接口</b>
 *
 * @author yvvb
 * @date 2025/5/5
 */
public interface DataVersionChain<T, E extends DataVersion<T>> {
    T getDataId();

    Class<? extends BusinessModel> getBusinessModelClass();

    LocalDate getGenesisDate();

    Optional<LocalDate> getDeletedDate();

    Optional<E> findEffectiveVersion(LocalDate queryDate);

    Optional<E> findVersionByVersionDateEq(LocalDate versionDate);

    Optional<E> findVersionByExpirationDateEq(LocalDate expirationDate);

    Optional<E> findPrecedingVersion(E dataVersion);

    Optional<E> findFollowingVersion(E dataVersion);

    Collection<E> getAllVersions();

    Collection<E> getChangedVersions();

    Collection<E> getRemovedVersions();

    Collection<E> getBehindVersions(E current);

    Collection<E> getPrecedingVersions(E current);

    Collection<E> getVersionsByVersionDateBetween(LocalDate startDate, LocalDate endDate);

    Collection<E> getVersionsByExpirationDateBetween(LocalDate startDate, LocalDate endDate);

    Collection<E> getVersionsByRangeCross(LocalDate startDate, LocalDate endDate);

    OpResult<ErrorType> modify(LocalDate editDate, DataVersionModifyModel modifyModel);

    OpResult<ErrorType> delete(LocalDate deleteDate);

    OpResult<ErrorType> move(E movedVersion, LocalDate targetDate);

    OpResult<ErrorType> remove(E removedVersion);

    OpResult<ErrorType> duelChangePoint(ChangePoint<T, E> changePoint);
}
